package com.project.utils;

import cn.hutool.core.date.DateUtil;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author qjj
 * @create 2022/3/29 11:26
 */
@Component
public class OrderUtils {
    @Resource
    private ValueOperations<String, Object> valueOperations;

    public String getOrderNumber() {
        Long orderNumber1 = valueOperations.increment("orderNumber");
        String format = String.format("%04d", orderNumber1);
        Date date = new Date();
        String orderNumber = DateUtil.format(date, "yyyyMMddHHmmss") + format;
        return orderNumber;
    }

    public Long getImgId(){
        return valueOperations.increment("imgId");
    }
}
